Skip to content

Finalize terminal PR orchestration in the single-job flow - #501

Draft
sepo-agent-app[bot] wants to merge 1 commit into
mainfrom
agent/implement-issue-496/codex-31935330479
Draft

Finalize terminal PR orchestration in the single-job flow#501
sepo-agent-app[bot] wants to merge 1 commit into
mainfrom
agent/implement-issue-496/codex-31935330479

Conversation

@sepo-agent-app

Copy link
Copy Markdown

Summary

  • finalize terminal PR stops in the current progress note or trusted sepo-agent-orchestrate-stop fallback
  • include cumulative planner summaries and human requester mentions without changing the single-job architecture or permissions
  • best-effort collapse only older trusted conversation artifacts after exact successful outcomes, preserving the current note, pending handoffs, formal reviews, and non-success context
  • isolate optional parent-report failures, keep cleanup failures non-fatal, and surface publication failures
  • update focused orchestration documentation and regression coverage without release-note changes

Verification

  • npm --prefix .agent run build
  • node --test .agent/dist/__tests__/orchestrate-handoff-cli.test.js .agent/dist/__tests__/review-summary-minimize.test.js
  • env -u GITHUB_OUTPUT npm --prefix .agent run test:runtime
  • npm --prefix .agent run check:workflow
  • npm --prefix .agent run check:docs
  • git diff --check

Closes #496

@sepo-agent-app

sepo-agent-app Bot commented Aug 16, 2026

Copy link
Copy Markdown
Author

Sepo is dispatching follow-up automation.

Source Next Target Round Status
implement review PR #501 3 / 40 Dispatched

Reason: agent planner selected review: Implementation succeeded and produced open PR #501 with passing checks; an independent review is the appropriate next step.

@sepo-agent-app

Copy link
Copy Markdown
Author

Rubrics Review

Total Score Verdict Rubrics Scored
98 PARTIAL 14
Dimension Rubric Result Score Evidence
coding_workflow / generic Validate delegated route authorization pass 8/8 The original requester association and access policy remain enforced by the existing preflight; the change does not broaden dispatch authorization.
coding_workflow / generic Generate context-derived artifact metadata pass 7/7 The planner now produces a cumulative user_message, which is combined with source outcome, target, round, reason, run ID, and validated requester context in the terminal formatter.
coding_workflow / generic Read docs and linked context first pass 6/6 The seven-file implementation follows the lean boundary and acceptance criteria in issue #496 and the original behavior requested in issue #452.
coding_workflow / generic Leave release notes to release preparation pass 8/8 The changed-file set contains no changelog or release-note edits.
communication / generic Keep status comments compact pass 6/6 Final notes use a short outcome heading, optional requester and summary, stable metadata bullets, and one next-step sentence rather than raw execution logs.
coding_workflow / generic Make surgical changes pass 8/8 The PR stays within seven directly relevant files: the existing CLI and minimizer, focused tests, prompt/workflow wiring, and two matching docs pages.
coding_workflow / generic Reuse existing code pass 8/8 It reuses tryMergeProgressFinalComment, upsertPrCommentByMarker, appendRunDisplayFooter, and the existing trusted-comment minimization infrastructure in the handoff path.
coding_workflow / generic Separate decision gates from action authorization pass 8/8 The workflow retains pull-requests: read, performs access preflight before planning, and leaves final publication to deterministic runtime code; no approval or merge permission was added. Permissions.
coding_workflow / generic Make user-facing automation idempotent partial 5/7 Progress comments are reused and fallback notes are upserted by the stable stop marker. However, cleanup after updating an older fallback note can fail to converge, as described below.
coding_workflow / generic Keep docs in sync pass 7/7 Both architecture and workflow usage document final-note reuse, requester mentions, success-only cleanup, and exclusions.
coding_workflow / generic Prefer explicit structured inputs pass 7/7 Agent handle, progress-comment ID, merge mode, planner response, and model display remain separate workflow-to-CLI fields. Workflow wiring.
coding_workflow / generic Surface stateful failures pass 7/7 Final-note publication failures fail the handoff step, while optional cleanup failures remain visible warnings and non-fatal; both behaviors have focused regression coverage.
coding_workflow / generic Comment on accepted workflow stops pass 6/6 Ordinary terminal PR stops now publish or update a visible note, including closed-PR stops, with regression coverage at lines 1525–1547.
coding_style / generic Prefer simple implementations pass 7/7 The change remains an extension of the existing single-job handoff flow, without the rejected planner/write-job split, session machinery, new subsystem, or public configuration surface.

Notes

  • The principal score drivers are the restored seven-file scope, unchanged permission model, reuse of existing helpers, synchronized documentation, and focused terminal-state/failure tests.
  • The hosted PR check passes on current head 821ddc7e.
  • Smallest useful follow-up: cover fallback update plus cleanup in one regression and use an ordering boundary that reflects the final note’s current update, not its original database ID.

Findings

  • WARNING: When progress-note reuse is unavailable, the marker upsert may update a final note created during an earlier run. Cleanup then uses that unchanged comment database ID as its cutoff (handoff lines 1245–1269), while the minimizer accepts only artifacts with smaller IDs (minimizer lines 324–328). Consequently, review and handoff artifacts created after that old note—but before its current update—remain visible. The fallback test disables cleanup, while the cleanup test assumes the current final comment has a newer ID, so the combined rerun case is uncovered. This makes rerun cleanup only partially idempotent, though final-note publication itself remains deduplicated and cleanup is explicitly best-effort.

Final Rubric Verdict

PARTIAL


codex | gpt-5.6-sol[max] | Macmini-runner-3

AGENT_COLLAPSE_OLD_REVIEWS: ${{ vars.AGENT_COLLAPSE_OLD_REVIEWS }}
AGENT_HANDLE: ${{ vars.AGENT_HANDLE || '@sepo-agent' }}
AGENT_PROGRESS_COMMENT_ID: ${{ steps.planner.outputs.progress_comment_id }}
AGENT_PROGRESS_FINAL_COMMENT_MODE: merge

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The progress reporter creates this comment with the job-scoped github.token, but this step runs with the resolved App/PAT as GH_TOKEN, and the CLI calls tryMergeProgressFinalComment without an explicit token. Pass AGENT_PROGRESS_GITHUB_TOKEN: ${{ github.token }} through to the merger; otherwise App-backed final edits can retrigger Agent Entrypoint, violating the non-recursive final-replacement contract merged in #500. Please add a token-sensitive merge/fallback regression.

) {
return false;
}
if (automationMode !== "agent") return true;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heuristics mode has no planner user_message, yet this branch treats every exact source outcome as cleanup-eligible. The final note then contains only generic action/conclusion metadata while cleanup can minimize the detailed source synthesis. Keep publishing the terminal note, but fail closed on cleanup when no substantive cumulative summary is available, and cover that heuristics path with a regression.

try {
const finalCommentId = currentFinalCommentId(prNumber, knownCommentId);
if (!finalCommentId) return;
const collapsed = collapsePreviousPrConversationArtifacts({

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cleanup pass authenticates only as the ambient App/PAT, while the helper limits matches to comments authored by its GraphQL viewer. After #500, workflow-finalized fix/progress artifacts are github-actions[bot]-authored and this pass cannot collapse them. Please add an independently caught workflow-token cleanup pass, preserving the same cutoff and human/unrelated-bot exclusions, with cross-identity coverage.

@sepo-agent-app

Copy link
Copy Markdown
Author

AI Review Synthesis

Dual-agent review by Claude and Codex.
Requested by @lolipopshock.

Summary of PR/Issue

PR #501 implements the lean redo requested by issue #496. It finalizes terminal PR orchestration in the current progress comment or a marker-based fallback, includes cumulative summaries and human requester mentions, and collapses older trusted artifacts after successful outcomes. The change preserves the single-job architecture and existing permissions across seven focused files. Documentation and regression coverage are updated without release-note changes.

Review

The architecture and scope are appropriate, and the hosted Test Scripts check passes. However, current head 821ddc7e has one blocking token-identity regression and two cleanup correctness warnings. Claude recommended SHIP, while Codex identified the token and summary defects; current code and the merged #500 token contract support the latter findings.

Issue Severity Disposition Description
Progress-comment replacement uses the wrong token identity BLOCKING FIX_IN_PR The progress comment is created with github.token, but final replacement uses the resolved App/PAT. App-backed edits can retrigger Agent Entrypoint or fall back to a second note, violating #500’s non-recursive contract.
Cleanup misses workflow-authored artifacts WARNING FIX_IN_PR Cleanup authenticates only as the App/PAT and therefore cannot match github-actions[bot] artifacts under the helper’s same-viewer guard.
Heuristics cleanup can remove the only substantive summary WARNING FIX_IN_PR Heuristics stops have no planner user_message, yet can minimize the detailed source synthesis after publishing only generic outcome metadata.
Reused fallback-note cutoff can leave newer artifacts visible INFO FOLLOW_UP Updating an old marker comment preserves its old database ID, so later artifacts fall outside the cleanup cutoff and remain visible. This is safe, best-effort incompleteness.

Progress

  • The PR is correctly refocused to seven directly relevant files; release notes remain untouched.
  • The hosted Test Scripts check passes, and git diff --check is clean.
  • Posted inline findings for progress-token wiring, cross-identity cleanup, and heuristics summary preservation.
  • No inline comments or review threads existed before posting; none were replied to, minimized, or resolved.
  • The fallback-note cutoff is already covered by the existing rubrics review, so no duplicate inline comment was added.
  • Claude’s additional INFO observations—fatal publication failure, missing sanitizer negative coverage, and an extra fallback lookup—are optional follow-ups; publication failure behavior is intentional under Refocus orchestration finalization on a lean single-job design #496.

Issue Details

Progress-comment replacement uses the wrong token identity

Cause: The workflow passes the progress comment ID but not github.token; the merger call consequently uses ambient App/PAT authentication.

Candidate solutions: Pass AGENT_PROGRESS_GITHUB_TOKEN: ${{ github.token }} into the handoff CLI and supply it to tryMergeProgressFinalComment. Add token-sensitive merge and failure-fallback coverage.

Comments: This is the same non-recursive final-replacement invariant established by merged PR #500.

Cleanup misses workflow-authored artifacts

Cause: Terminal cleanup runs only with ambient App/PAT authentication, while the helper accepts only comments authored by its authenticated viewer.

Candidate solutions: Retain the App/PAT pass and add an independently caught workflow-token pass when the tokens differ, preserving the current cutoff and human/unrelated-bot exclusions. Add cross-identity regression coverage.

Heuristics cleanup can remove the only substantive summary

Cause: Success validation accepts heuristics outcomes without a summary, while the final formatter and cleanup can replace the detailed source synthesis with generic metadata.

Candidate solutions: Continue publishing the terminal note, but make cleanup fail closed when no substantive cumulative summary exists. Add a heuristics-mode regression without expanding summary provenance.

Comments: This preserves the lean scope and avoids reintroducing the broader machinery rejected in earlier attempts.

Reused fallback-note cutoff can leave newer artifacts visible

Cause: Cleanup compares artifact database IDs against the reused final comment’s unchanged ID, so artifacts created after that old comment remain above the cutoff.

Candidate solutions: In a follow-up, use an update-aware ordering boundary or explicitly exclude the current final node while retaining fail-closed protections.

Comments: The rubric reviewer rated this a warning, while Claude treated it as INFO. Because cleanup is explicitly best-effort and the failure mode leaves comments visible, this synthesis classifies it as INFO/FOLLOW_UP.

Recommended Next Step

FIX_PR: One bounded automated fix should thread the workflow token through finalization, add dual-identity cleanup, guard summary-less heuristics cleanup, and add focused regressions without changing the single-job design.

Final Verdict

NEEDS_REWORK

Action Items

  • FIX_IN_PR: Use the job-scoped token for progress-comment replacement and add token-sensitive merge/fallback coverage.
  • FIX_IN_PR: Run terminal cleanup for both distinct App/PAT and workflow-token identities with cross-identity coverage.
  • FIX_IN_PR: Prevent successful heuristics cleanup when no substantive cumulative summary is available.

codex | gpt-5.6-sol[max] | Macmini-runner-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Handled by the agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refocus orchestration finalization on a lean single-job design

1 participant